package package1;

import java.io.File;
import java.io.IOException;
/**
 *  parse path list from 1.txt
 *  pack path on the list into zip
 *  
 *  set a = C:\Users\Administrator\Desktop\test
 *  set b = C:\Users\Administrator\Desktop\hello
 *  java -jar TestForFolderPack.jar a b
 */
public class TestForFolderPack {
	
	public static void main(String[] args) throws IOException {
		for(String path:args){
			packFolder(path);
		}
	}
	private static void packFolder(String folderAddr) throws IOException {
		File folder = new File(folderAddr);
		String jarName = folder.getName();
		String cmd = "jar vcf "+getDesktop()+jarName+".zip "+folderAddr;
		run(cmd);
	}
	private static void run(String cmd) throws IOException {
		Runtime.getRuntime().exec(cmd);
	}
	private static String getDesktop() {
		return System.getenv("USERPROFILE") + "\\desktop\\";
	}
	public static String getCurrentFolder() {
		return System.getProperty("user.dir")+"\\";
	}
}
